package com.server.test.servlet.console;

import java.io.IOException;
import java.io.PrintWriter;
import java.sql.SQLException;
import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import net.arnx.jsonic.JSON;
import com.server.test.command.response.OrderInfoResponeBean;
import com.server.test.database.BaseDao;
import com.server.test.pojo.OrderInfo;

public class SelectOrderServlet extends HttpServlet{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	@Override
	protected void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		
		// 将请求、响应的编码均设置为UTF-8（防止中文乱码）  
        request.setCharacterEncoding("UTF-8");  
        response.setCharacterEncoding("UTF-8");  
		BaseDao baseDao = new BaseDao();
		List<OrderInfo> list = null;
		try {
			list = baseDao.executeQuery(OrderInfo.class, "select * from orderinfo", null);
		} catch (SQLException e) {
			e.printStackTrace();
		}
		
		OrderInfoResponeBean orderInfoResponeBean = new OrderInfoResponeBean();
		orderInfoResponeBean.setListOrderInfo(list);
		PrintWriter out = response.getWriter();
		out.write(JSON.encode(orderInfoResponeBean));
		
	}
}
